package cn.com.scitc.mapper;

import cn.com.scitc.model.User;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

public interface UserMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @mbg.generated Tue May 23 08:05:50 CST 2023
     */
    @Delete({
        "delete from user",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @mbg.generated Tue May 23 08:05:50 CST 2023
     */
    @Insert({
        "insert into user (id, loginId, ",
        "userName, mobile, ",
        "gender, password, ",
        "valid)",
        "values (#{id,jdbcType=INTEGER}, #{loginId,jdbcType=VARCHAR}, ",
        "#{userName,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, ",
        "#{gender,jdbcType=INTEGER}, #{password,jdbcType=VARCHAR}, ",
        "#{valid,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=true, resultType=Integer.class)
    int insert(User row);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @mbg.generated Tue May 23 08:05:50 CST 2023
     */
    @Select({
        "select",
        "id, loginId, userName, mobile, gender, password, valid",
        "from user",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="loginId", property="loginId", jdbcType=JdbcType.VARCHAR),
        @Result(column="userName", property="userName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="gender", property="gender", jdbcType=JdbcType.INTEGER),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="valid", property="valid", jdbcType=JdbcType.INTEGER)
    })
    User selectByPrimaryKey(Integer id);

    @Select({
            "select",
            "id, loginId, userName, mobile, gender, password, valid",
            "from user",
            "where loginId = #{loginId,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="loginId", property="loginId", jdbcType=JdbcType.VARCHAR),
            @Result(column="userName", property="userName", jdbcType=JdbcType.VARCHAR),
            @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
            @Result(column="gender", property="gender", jdbcType=JdbcType.INTEGER),
            @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
            @Result(column="valid", property="valid", jdbcType=JdbcType.INTEGER)
    })
    User selectByLoginId(String loginId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @mbg.generated Tue May 23 08:05:50 CST 2023
     */
    @Select({
        "select",
        "id, loginId, userName, mobile, gender, password, valid",
        "from user"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="loginId", property="loginId", jdbcType=JdbcType.VARCHAR),
        @Result(column="userName", property="userName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR),
        @Result(column="gender", property="gender", jdbcType=JdbcType.INTEGER),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="valid", property="valid", jdbcType=JdbcType.INTEGER)
    })
    List<User> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table user
     *
     * @mbg.generated Tue May 23 08:05:50 CST 2023
     */
    @Update({
        "update user",
        "set loginId = #{loginId,jdbcType=VARCHAR},",
          "userName = #{userName,jdbcType=VARCHAR},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "gender = #{gender,jdbcType=INTEGER},",
          "password = #{password,jdbcType=VARCHAR},",
          "valid = #{valid,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(User row);
}